package com.shawn.baseappbygroovydsl.ui.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.chad.library.adapter4.BaseQuickAdapter
import com.shawn.baseappbygroovydsl.R
import com.shawn.baseappbygroovydsl.bean.BeanTask
import com.shawn.baseappbygroovydsl.databinding.AdapterRecyclerStyle1Binding
import kotlin.properties.Delegates

/**
 * @author Secret
 * @since 2023/5/15
 */
class AdapterRecyclerViewStyle1 : BaseQuickAdapter<BeanTask, AdapterRecyclerViewStyle1.VH>() {
    var signDay by Delegates.observable(0, onChange = { _, old, new ->
        if (old != new) {
            notifyDataSetChanged()
        }
    })

    // 自定义ViewHolder类
    class VH(
        parent: ViewGroup,
        val binding: AdapterRecyclerStyle1Binding = AdapterRecyclerStyle1Binding.inflate(
            LayoutInflater.from(parent.context), parent, false
        ),
    ) : RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): VH {
        // 返回一个 ViewHolder
        return VH(parent)
    }

    override fun onBindViewHolder(holder: AdapterRecyclerViewStyle1.VH, position: Int, item: BeanTask?) {
        Glide.with(holder.binding.ivThumb)
            .load(R.mipmap.ic_girl)
            .placeholder(R.drawable.shape_cccccc_10)
            .into(holder.binding.ivThumb)
    }

}